'use strict';
module.exports = app => {
  const { STRING, TINYINT } = app.Sequelize;

  const Permission = app.model.define('permission', {
    // id: { type: INTEGER, primaryKey: true, autoIncrement: true },
    name: STRING(60),
    mark: STRING(60),
    mark_name: STRING(60),
    url: STRING(255),
    action: STRING(60),
    description: STRING(255),
    state: TINYINT(1),
    authentication: TINYINT(1),
    authorization: TINYINT(1),
  });
  Permission.associate = () => {
    app.model.Permission.belongsToMany(app.model.Role, {
      through: app.model.RolePermission,
      foreignKey: 'permission_id',
      otherKey: 'role_id',
    });
  };


  return Permission;
};
